package tcpOptimized;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(10098);
        //创建一个线程池,不然每次都新建一个线程在销毁太浪费资源
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        while (true) {
            Socket socket = serverSocket.accept();
            executorService.submit(new ServerImpl(socket));
        }
    }
}
